// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import axios from 'axios'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI);
Vue.config.productionTip = false
// 读取Cookie
Vue.prototype.getCookie = function
  (c_name) {
  if (document.cookie.length > 0) {
    var c_start = document.cookie.indexOf(c_name + "=");
    if (c_start != -1) {
      c_start = c_start + c_name.length + 1;
      var c_end = document.cookie.indexOf(";", c_start);
      if (c_end == -1) c_end = document.cookie.length;
      return unescape(document.cookie.substring(c_start, c_end));
    }
  }
  return "";
}
// axios配置
axios.defaults.baseURL = "https://ai.easy-ip.com.cn/api";
//axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded';
// axios.defaults.headers.common['token'] = "sdfdf"
// 添加响应拦截器
axios.interceptors.response.use(function (response) {
  if (response.data.code == 0) {
     return response.data;
  }else{
    //this.$alert(response.data.message, '错误')
  }
}, function (error) {
  if (error.response.status == 401) {
    console.log(error.response.status)
    window.location.href = "/"
  }
});
Vue.prototype.$http = axios;

import '../static/css/style.css';
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
